using Whisper.CommonTypes;
using Whisper.CommonTypes.RequestResponse;
using Whisper.Interfaces;
using Whisper.RequestResponseMessages;

namespace Whisper.Services
{
    public class ConversationService : IConversationService
    {
        private static readonly ConversationList conversations = new ConversationList();


        public GetListOfConversationsResponse GetListOfConversations(GetListOfConversationsRequest request)
        {
            var response = new GetListOfConversationsResponse
                               {
                                   Body = conversations
                               };
            return response;
        }

        public CreateConversationResponse CreateConversation(CreateConversationRequest request)
        {
            var wasSuccesfull = true;
            try
            {
                conversations.Add(new Conversation {Name = request.Body});
            }
            catch
            {
                wasSuccesfull = false;
            }
            return new CreateConversationResponse {Body = wasSuccesfull};
        }
    }
}